import java.io.*;
public class Test01 {
    public static void main(String[ ] args) throws Exception {
        // 字节流拷贝
        FileInputStream in = new FileInputStream("d:/test.txt");
        FileOutputStream out = new FileOutputStream("d:/test2.txt");
        while (true) {
            byte[ ] buf = new byte[1024];
            int len = in.read(buf);
            if(len == -1){
                break;
            }
            out.write(buf, 0, len);
        }
        in.close( );
        out.close( );

//         字符流拷贝
        BufferedReader bf = new BufferedReader(new FileReader("d:/test.txt"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("d:/test2.txt"));
        String str;
        while ((str = bf.readLine( )) != null) {
            bw.write(str);
            bw.newLine( );
        }
        System.out.println(str);
        bf.close( );
        bw.close( );
    }
}
